import { Result, message } from 'antd';
import { useEffect, useState } from 'react';

import type { FC } from 'react';

import { handleCountDown } from '@/util/utils';

const PayStatus: FC = () => {
  const [verificationCode, setVerificationCode] = useState(false);
  const [countDownSecond, setCountDownSecond] = useState(3);
  function CloseWebPage() {
    setTimeout(() => {
      window.opener = null;
      window.close();
      message.success('购买成功');
    }, 3000);
  }

  useEffect(() => {
    CloseWebPage();
    console.log(verificationCode);
    handleCountDown(3, setCountDownSecond, setVerificationCode);
  }, []);
  return (
    <>
      <Result
        status="success"
        title="支付成功！"
        subTitle={`${countDownSecond}` + '秒后自动关闭页面'}
        extra={[]}
      />
    </>
  );
};
export default PayStatus;
